/**
  ******************************************************************************
  * @file   :   main.c
  * @version:
  * @author :
  * @brief  :
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright(c) . BLUEX Microelectronics.
  * All rights reserved.</center></h2>
  *
  *
  ******************************************************************************
  */

/* includes ------------------------------------------------------------------*/

#include "bx_kernel.h"

#include "user_app.h"


#include "bx_service_adc.h"

#include "bx_shell.h"


/* private define ------------------------------------------------------------*/


/* private typedef -----------------------------------------------------------*/


/* private variables ---------------------------------------------------------*/

/* exported variables --------------------------------------------------------*/
u32 temp;
u32 volt_mv;
u32 bat_value;
u32 channel = 0;

/*============================= private function =============================*/

/*========================= end of private function ==========================*/


/*============================= exported function ============================*/
/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
void user_init( void )
{
    
	bxs_adc_register();
	
}

/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
void user_app( void )
{
	
	s32 id = bxs_adc_id();

	bx_call(id,BXM_OPEN,0,0);


	bx_repeat(id,BXM_ADC_TEMPERATURE , (u32)&temp , 0, 500);

    bx_subscibe(id, BXM_ADV_TEMP_DATA_UPDATE, 0 , 0);
}




/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
bx_err_t app_msg_handle( u32 msg,u32 param0,u32 param1 )
{
	return BX_OK;
}

/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
bx_err_t user_msg_handle_func(s32 id, u32 msg,u32 param0,u32 param1 )
{
   if(bx_msg_source() != bxs_adc_id())
   	{
		return 0;
   }
   
	switch(msg)
	{
		case BXM_ADV_VOLT_DATA_UPDATE:
			bxsh_logln("param0 = %d\tparam1 = %d\tvolt_mv = %d",param0,param1,volt_mv);
			break;

		case BXM_ADV_TEMP_DATA_UPDATE:
			bxsh_logln("param0 = %d\tparam1 = %d\ttemp = %d",param0,param1,temp);
			break;

		case BXM_ADV_BAT_DATA_UPDATE:
			bxsh_logln("param0 = %d\tparam1 = %d\tbat_value = %d",param0,param1,bat_value);
			break;

		default:
			break;
	}
    return BX_OK;
}
/*========================= end of exported function =========================*/


/*============================= import function ==============================*/

/*=========================== end of import function =========================*/


/*============================ interrupt function ============================*/

/*========================= end of interrupt function ========================*/

  
/******************** (C) COPYRIGHT BLUEX **********************END OF FILE****/



